using System;
using System.Collections;
using System.Collections.Generic;
using System.Xml;
using System.Xml.Serialization;
using UnityEngine;

public class SessionStats
{
	
	[XmlAttribute("name")]
	public string Name{ get; set; }
	
	[XmlElement("totalTime")]
    public int TotalTime{ get; set; }
	
	[XmlElement("totalMoves")]
    public int TotalMoves{ get; set; }
	
	[XmlElement("totalUsedUndo")]
    public int TotalUsedUndo{ get; set; }

	[XmlElement("totalCanceledUndo")]
    public int TotalCanceledUndo{ get; set; }
	
	[XmlElement("totalStates")]
    public int TotalStates{ get; set; }
	
	[XmlElement("totalUsedStates")]
    public int TotalUsedStates{ get; set; }
	
	[XmlElement("totalDeletedStates")]
    public int TotalDeletedStates{ get; set; }
	
	[XmlElement("totalHints")]
    public int TotalHints{ get; set; }
	
	[XmlElement("levels")]
    public List<LevelStats> Levels{ get; set; }

	
	public SessionStats(){
		
	}
	
	public SessionStats(List<LevelStats> lvs){
		Levels = lvs;
		
		Name = DateTime.Now.ToString("ddMMHHmm");
		
		TotalTime = 0;
		TotalMoves = 0;
		TotalStates = 0;
		TotalUsedStates = 0;
		TotalUsedUndo = 0;
		TotalCanceledUndo = 0;
		TotalDeletedStates = 0;
		TotalHints = 0;
		
		foreach(LevelStats ls in lvs){
			TotalTime += ls.ResTime;
			TotalMoves += ls.Moves;
			TotalStates += ls.States;
			TotalUsedStates += ls.UsedStates;
			TotalUsedUndo += ls.UsedUndo;
			TotalCanceledUndo += ls.CanceledUndo;
			TotalDeletedStates += ls.DeletedStates;
			TotalHints += ls.Hints;
		}
	}
		
}

